package com.life.goal.infrastructure.goal.impl;

import com.life.goal.domain.entity.User;
import com.life.goal.domain.support.UserRepository;
import com.life.goal.infrastructure.goal.converter.UserConverter;
import com.life.goal.infrastructure.goal.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserRepositoryImpl implements UserRepository {

    @Resource
    private UserMapper userMapper;

    @Override
    public boolean existUserName(String userName) {
        return userMapper.existUserName(userName) > 0;
    }

    @Override
    public User findUserByNameAndPwd(String userName, String password) {
        return UserConverter.INSTANCE.toUser(userMapper.findUserByNameAndPwd(userName, password));
    }
}
